package com.bigkoo.convenientbanner;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

/**
 * 页面翻转控件，极方便的广告栏
 * 支持无限循环，自动翻页，翻页特效
 *
 * @author Sai 支持自动翻页
 */
public class ConvenientTitleBanner<T> extends Banner<T> {
    private TextView title;

    public ConvenientTitleBanner(Context context) {
        super(context);
    }

    public ConvenientTitleBanner(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }


    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public ConvenientTitleBanner(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public ConvenientTitleBanner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void init(Context context) {
        View hView = LayoutInflater.from(context).inflate(R.layout.include_viewpager_title, this, true);
        viewPager = hView.findViewById(R.id.cbLoopViewPager);
        loPageTurningPoint = hView.findViewById(R.id.loPageTurningPoint);
        title = hView.findViewById(R.id.title);
        initViewPagerScroll();
        viewPager.setOffscreenPageLimit(3);
        adSwitchTask = new AdSwitchTask(this);
    }

    public void setTitle(String title) {
        this.title.setText(title);
    }
}
